<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>make_insert (CrudMaker)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/CrudMaker.rb, line 15</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_insert</span>
    <span class="ruby-identifier">insert_template</span>  = <span class="ruby-value str">'INSERT INTO \n(#{col_list})\n VALUES\n( #{rec_list} )\n;'</span> 
    <span class="ruby-identifier">f</span> = <span class="ruby-keyword kw">false</span>
    <span class="ruby-identifier">col_list</span> = <span class="ruby-value str">&quot;&quot;</span>
    <span class="ruby-identifier">rec_list</span> = <span class="ruby-value str">&quot;&quot;</span>
    <span class="ruby-ivar">@col_names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">col</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">then</span>
        <span class="ruby-identifier">col_list</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">col</span>.<span class="ruby-identifier">downcase</span>
        <span class="ruby-identifier">rec_list</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;the_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@table_name</span>.<span class="ruby-identifier">capitalize</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;_rec.&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">col</span>.<span class="ruby-identifier">capitalize</span>
        <span class="ruby-identifier">f</span> = <span class="ruby-keyword kw">true</span>
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-identifier">col_list</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;\n, &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">col</span>.<span class="ruby-identifier">downcase</span>
        <span class="ruby-identifier">rec_list</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;\n, the_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@table_name</span>.<span class="ruby-identifier">capitalize</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;_rec.&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">col</span>.<span class="ruby-identifier">capitalize</span>
      <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#if f==false</span>
    <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt">#loop</span>
    <span class="ruby-ivar">@insert_sql</span> = <span class="ruby-identifier">eval</span>( <span class="ruby-value str">'&quot;'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">insert_template</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'&quot;'</span> )
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>